﻿using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApp64.Models;

namespace WpfApp64
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ObservableCollection<Person> persons = new ObservableCollection<Person>();
            for (int i = 0; i <10; i++)
            {
                persons.Add(new Person
                {
                    Id = i,
                    Name = "Tom" + i,
                    Age = 18 + i,
                    Number = 100 +i,
                    Gerder = Gerder.M,
                    Description = "Description DescriptionDescription DescriptionDescription"
                });
            }

            DgPersons.ItemsSource = persons;

            //Enum.GetValues(typeof(Gerder)).Cast<Gerder>().ToList();
        }

        private void DgPersons_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            if (e.Row.DataContext is Person person)
            {
                if (person.Age > 20)
                {
                    e.Row.Background = Brushes.LightCoral;
                }
            }
        }

        private void DgPersons_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sender is DataGrid dataGrid)
            {
                int count = dataGrid.SelectedItems.Count;

            }
        }
    }
}